package org.example.pattern;

//双重检查锁定
public class SingletonPattern {
    private static volatile SingletonPattern instance = null;

    private SingletonPattern() {};

    public static SingletonPattern getInstance() {
        if (instance == null) {
            synchronized(SingletonPattern.class) {
                if (instance == null) {
                    instance = new SingletonPattern();
                }
            }
        }
        return instance;
    }
}
